package com.sfx.concurrent.demo.concurrent.ImmutableIssue;

import lombok.extern.slf4j.Slf4j;

import java.text.ParseException;
import java.text.SimpleDateFormat;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: sfx
 * Date: 2023-01-21
 * Time: 16:37
 */
@Slf4j(topic = "c.Date")
public class DateUnSafe {

    public static void main(String[] args) {
        SimpleDateFormat sidf = new SimpleDateFormat("yyyy-MM-dd");
        for(int i =0;i<10;++i) {
            new Thread(()->{
                synchronized (sidf) {
                    try {
                        log.debug("{}",sidf.parse("2023-01-21"));
                    } catch (ParseException e) {
                        log.error("{}",e);
                    }
                }
            }).start();
        }
    }

}
